package cn.gogetter.classifiers;

import java.io.File;

import weka.classifiers.trees.J48;
import weka.core.Instances;
import weka.core.converters.ArffLoader;

public class ClassifiersJ48 {
	public static void main(String[] args) throws Exception{
		// 加载数据
		Instances data = null;
		String path = new File("").getAbsolutePath()+"\\data\\";
		ArffLoader loader = new ArffLoader();
		loader.setFile(new File(path + "weather.nominal.arff"));
		data = loader.getDataSet();
		data.setClassIndex(data.numAttributes() - 1);
		J48 classifier = new J48();
		String[] options = new String[1];
		options[0] = "-U"; // 未裁剪树选项
		classifier.setOptions(options);
		
		
		// 训练
		classifier.buildClassifier(data);
		System.out.println("生成模型："+classifier);
		
	}
}
